package com.ydkj.a37e_mall.Classes.Acitivity.BaseActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ydkj.a37e_mall.R;
import com.ydkj.a37e_mall.Resource.Utils.SharedPreferencesUtil;
import com.ydkj.a37e_mall.Resource.View.StatusBarUtil;

/**
 * Created by Administrator on 2017/1/18.
 * 我的消息
 */

public class MyNewsActivity extends BaseActivity {
    private Activity mActivity;
    private ImageView img_back;
    private RelativeLayout rly_system_message, rly_vip_message;
    private TextView tv_system_message_hint, tv_vip_message_hint;
    private SharedPreferencesUtil sharedPreferencesUtil;
    private String secret;
    private int page;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.all_message);
        init();
        initWindow();
    }

    private void initWindow() {
        StatusBarUtil.setColor(mActivity, getResources().getColor(R.color.A000000), 0);

    }

    private void init() {
        mActivity = this;
        sharedPreferencesUtil = SharedPreferencesUtil.getInstance(mActivity);
        img_back = (ImageView) this.findViewById(R.id.img_back);
        rly_system_message = (RelativeLayout) this.findViewById(R.id.rly_system_message);
        rly_vip_message = (RelativeLayout) this.findViewById(R.id.rly_vip_message);
        tv_system_message_hint = (TextView) this.findViewById(R.id.tv_system_message_hint);
        tv_vip_message_hint = (TextView) this.findViewById(R.id.tv_vip_message_hint);

//        GetMessageNum();

        Log.e("url", "vip_num==" + sharedPreferencesUtil.getVipMessage());
        Log.e("url", "system_num==" + sharedPreferencesUtil.getSystemMessage());

        if (sharedPreferencesUtil.getVipMessage() == 0) {
            tv_vip_message_hint.setVisibility(View.GONE);
        } else {
            tv_vip_message_hint.setVisibility(View.VISIBLE);
            if (sharedPreferencesUtil.getVipMessage() > 99) {
                tv_vip_message_hint.setText("99");
            } else {
                tv_vip_message_hint.setText(sharedPreferencesUtil.getVipMessage() + "");
            }
        }

        if (sharedPreferencesUtil.getSystemMessage() == 0) {
            tv_system_message_hint.setVisibility(View.GONE);
        } else {
            tv_system_message_hint.setVisibility(View.VISIBLE);
            if (sharedPreferencesUtil.getSystemMessage() > 99) {
                tv_system_message_hint.setText("99");
            } else {
                tv_system_message_hint.setText(sharedPreferencesUtil.getSystemMessage() + "");
            }
        }

        rly_vip_message.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(mActivity, MessageVip.class));
            }
        });
        rly_system_message.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(mActivity, MessageSystem.class));
            }
        });
        img_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("url", "messageVip_onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("url", "messageVip_onStop");
    }
}
